package com.wxtwxt.ruralmall.product.feign;

import com.wxtwxt.ruralmall.common.to.SkuEsModel;
import com.wxtwxt.ruralmall.common.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * Feign调用流程：
 * 1.构造请求数据，将对象转换为json
 *      RequestTemplate template = buildTemplateFromArgs.create(argv)
 * 2.发送请求进行执行（执行成功后解码响应数据）
 *      executeAndDecode(template);
 * 3.执行请求会有重试机制
 *      while(true) {
 *          try {
 *              executeAndDecode(template);
 *          }catch(Exception e) {
 *              try {
 *                  retryer.continueOrPropagate(e);
 *              }catch(Exception e) {
 *                  throw e;
 *              }
 *              continue;
 *          }
 *      }
 *
 * @author Wxt
 * @create 2023-03-15 13:59
 */
@FeignClient("ruralmall-search")
public interface SearchFeignService {
    @PostMapping("/search/save/product")
    R productStatusUp(@RequestBody List<SkuEsModel> skuEsModels);
}
